﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace MPViz
{
    class MPRel
    {
        public string from = "", to = "";
        public string type = "";
        public string label = "";

        public MPRel() { }
        public string toString4Dot() 
        {
            StringWriter sw = new StringWriter();

            sw.Write("{0}->{1}", from, to);
            
            // label
            if (label != "")
            {
                string name;
                if (type == "depend" || type == "tran") name = "\\<\\<" + label + "\\>\\>";
                else name = label;
                sw.Write("[label=\"{0}\"]", name);
            }

            switch (type)
            {
                case "aggre":
                    sw.Write("[arrowtail=ediamond arrowhead=none]");
                    break;
                case "general":
                    sw.Write("[arrowhead=empty]");
                    break;
                case "real":
                    sw.Write("[arrowhead=empty style=dotted]");
                    break;
                case "depend":
                case "prep":
                    sw.Write("[arrowhead=vee style=dotted]");
                    break;
                case "assoc":
                case "tran":
                    sw.Write("[arrowhead=vee]");
                    break;
            }
            sw.WriteLine();

            return sw.ToString();  
        
        
        
        }
    }
}
